import { requestAjax } from './http'

export interface UserVO {
  _id: string
  name: string
  code: string
  nickname: string
  pictureUrl: string
  roleCode: string
  roleCodes: string
  roleLevel: number
}

export interface UserMenuVO {
  title: string
  code: string
  name: string
  parentCode: string
  routeName: string
  icon: string
  type: string
  routerLink: any
  menuType: 'route' | 'form'
}

export interface UserRouteConfigVO {
  name: string
  code: string
  parentCode: string
  routeName: string
  type: 'menu' | 'action'
  icon: string
  sort: number
}

export interface UserFormConfigVO {
  _id: string
  name: string
  code: string
  parentCode: string
  routeName: string
  type: 'group' | 'form' | 'module'
  icon: string
  sort: number
}

export interface UserInfoVO {
  name: string
  nickname: string
  roleCode: string
  roleName: string
  roleLevel: number
  pictureUrl: string
  routeList: UserRouteConfigVO[]
  roleList: {
    label: string
    value: string
  }[]
  //formList: UserFormConfigVO[]
}

export function getPubAdminUserListPage(params?: any) {
  const res = {
    "code": 200,
    "status": 200,
    "data": [
      {
        "_id": "67e98c5e852c2e089cadb003",
        "createBy": "",
        "updateBy": "test1",
        "name": "test1",
        "code": "test1",
        "nickname": "用户1",
        "email": "xx@126.com",
        "roleCode": "userAdmin",
        "roleCodes": [
          "userAdmin",
          "default"
        ],
        "pictureUrl": "https://vxeui.com/resource/img/bq673.gif",
        "createTime": "2025-03-30T18:24:30.072Z",
        "updateTime": "2025-03-31T08:30:43.998Z",
        "roleLevel": 5
      },
      {
        "_id": "67e98c5e852c2e089cadb001",
        "createBy": "",
        "updateBy": "",
        "name": "root",
        "code": "root",
        "nickname": "超级用户",
        "email": "xx@163.com",
        "roleCode": "root",
        "roleCodes": [
          "root"
        ],
        "pictureUrl": "https://vxeui.com/resource/img/bq546.gif",
        "createTime": "2025-03-30T18:24:30.072Z",
        "updateTime": "2025-03-30T18:24:30.072Z",
        "roleLevel": -1
      },
      {
        "_id": "67e98c5e852c2e089cadb002",
        "createBy": "",
        "updateBy": "",
        "name": "admin",
        "code": "admin",
        "nickname": "管理员",
        "email": "xx@163.com",
        "roleCode": "admin",
        "roleCodes": [
          "admin",
          "userAdmin",
          "default"
        ],
        "pictureUrl": "https://vxeui.com/resource/img/bq546.gif",
        "createTime": "2025-03-30T18:24:30.072Z",
        "updateTime": "2025-03-30T18:24:30.072Z",
        "roleLevel": 3
      },
      {
        "_id": "67e98c5e852c2e089cadb004",
        "createBy": "",
        "updateBy": "",
        "name": "test2",
        "code": "test2",
        "nickname": "用户2",
        "email": "xx@qq.com",
        "roleCode": "default",
        "roleCodes": [
          "default"
        ],
        "pictureUrl": "https://vxeui.com/resource/img/bq987.gif",
        "createTime": "2025-03-30T18:24:30.072Z",
        "updateTime": "2025-03-30T18:24:30.072Z",
        "roleLevel": 100
      },
      {
        "_id": "67e98c5e852c2e089cadb005",
        "createBy": "",
        "updateBy": "",
        "name": "test3",
        "code": "test3",
        "nickname": "用户3",
        "email": "xx@163.com",
        "roleCode": "default",
        "roleCodes": [
          "default"
        ],
        "pictureUrl": "https://vxeui.com/resource/img/bq987.gif",
        "createTime": "2025-03-30T18:24:30.072Z",
        "updateTime": "2025-03-30T18:24:30.072Z",
        "roleLevel": 100
      }
    ],
    "msg": "",
    "page": {
      "pageSize": 10,
      "currentPage": 1,
      "total": 5
    }
  };
  return Promise.resolve(res);
  // return requestAjax({
  //   url: `/api/pub/admin/user/list/page/${params.pageSize}/${params.currentPage}`,
  //   method: 'get',
  //   params
  // })
}

export function postPubAdminUserCurrentChangeRole(data?: any) {
  return requestAjax({
    url: '/api/pub/admin/user/current/change/role',
    method: 'post',
    data
  })
}

export function postPubAdminUserSaveBatch(data?: any) {
  return requestAjax({
    url: '/api/pub/admin/user/save/batch',
    method: 'post',
    data
  })
}

export function deletePubAdminUserDelete(data?: any) {
  return requestAjax({
    url: '/api/pub/admin/user/delete',
    method: 'delete',
    data
  })
}


export function getUserinfo(params?: any) {
  return requestAjax({
    url: '/api/abp/application-configuration?includeLocalizationResources=false',
    method: 'get',
    params
  })
}
